<template>
  <div class="advantage">

    <div class="advantage-itme">
      <ul>
        <li v-for="(itme,index) in (ProductData as any)" :key="index">
          <div class="advantage-itme-context">
            <h3>{{ itme.title }}</h3>
            <span>{{ itme.content }}</span>
            <div class="advantage-itme-context-description">
              <p>{{ itme.description[0] }}</p>
              <p>{{ itme.description[1] }}</p>
              <p>{{ itme.description[2] }}</p>
            </div>

            <div>
              <el-button size="large">Learn more</el-button>
            </div>
          </div>

          <div class="advantage-itme-img">
            <img :src="itme.src"
              alt=""
              v-on:mouseover="zoomIn"
              v-on:mouseleave="zoomOut"
                           >
          </div>
        </li>
      </ul>
    </div>
  </div>
</template>

<script lang="ts">
import { getProduct} from '@/api/api'

  export default {
    setup(){

      const data = reactive({
        num: ref(20),
        startVal: ref(0),
        endVal: ref(100),
        ProductData: [],
      })

      getProduct('').then((res: any) => {
        data.ProductData = res._rawValue.title
        console.log(res);
        
      }).catch((err: any) => {
        console.log(err, '请求失败')
      })


      const zoomIn =(event: any) => {
        event.target.style.transform = 'scale(1.1)';
      }

      const zoomOut = (event: any) => {
        event.target.style.transform = 'scale(1)';
      }


      return{
        ...toRefs(data),
        zoomIn,
        zoomOut
      }

    },


    components: {
      
    },
  };
</script>


<style scoped>

  * {
    margin: 0;
    padding: 0;
  }

  .advantage {
    margin-top: 70px;
  }


  .advantage-title {
    position: relative;
    margin-top: 50px !important;
    margin-bottom: 50px;
    line-height: 40px;
  }

  .advantage-title h3 {
    font-size: 30px;

  }

  .advantage-itme ul {
    position: relative;
    display: grid;
    grid-template-columns: repeat(2, 2fr);
    grid-template-rows: auto;
    gap: 70px;

  }


  @media(max-width: 1000px){
    .advantage-itme ul {
      flex-direction: column;
      height: auto;
      width: 100%;
    }

    .advantage-itme ul li {
      height: auto;
    }
  }


  .advantage-itme ul li {
    position: relative;
    list-style: none;
    width: 880px;
    height: 475px;
    position: sticky;
    margin-left: 15px;
    top: 0;
    left: 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1); /* 阴影效果，可以根据需要进行调整 */
    /* padding: 10px; 头部区域的内边距，可以根据需要调整 */
    overflow: hidden;
    background: white;
  }

  .advantage-itme ul li div {

    height: auto;
    width: 100%;
    line-height: 70px;
  }

  .advantage-itme-context {
    line-height: 100px;
    text-align: left;
    margin-left: 80px;
  }
  .advantage-itme-context h3{
    font-size: 30px;
    color: rgb(245, 16, 16);

  }
  .advantage-itme-context span {
    font-weight: 100;
  }

  .advantage-itme-context-description {
    line-height: 20px !important;
    text-align: left;
    /* margin-left: 75px; */
  }

  .advantage-itme-context-description p {
    margin: 0;
    font-size: 15px;
  }


  .advantage-itme-img img {
    position: absolute;
    height: 278px;
    width: 200px;
    top: 95px;
    right: 70px;
    transition: transform 0.5s;
  }

  .advantage-itme-img :nth-child(4) img{
    height: 100px !important;
  }

  .el-button {
    width: 100px !important;
    height: 39px !important;
    margin-top: 52px  !important;
    font-size: 14px;
  }


</style>